package com.atguigu.seckill.vo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CodeResponse {

    private Integer code;
    private String message;
    private Object obj;

    //成功
    public static CodeResponse success(){
        return new CodeResponse(CodeResponseEnum.SUCCESS.getCode(),CodeResponseEnum.SUCCESS.getMessage(),null);
    }
    //成功,有返回对象
    public static CodeResponse success(Object obj){
        return new CodeResponse(CodeResponseEnum.SUCCESS.getCode(),CodeResponseEnum.SUCCESS.getMessage(),obj);
    }

    //失败
    public static CodeResponse error(CodeResponseEnum codeResponseEnum){
        return new CodeResponse(codeResponseEnum.getCode(),codeResponseEnum.getMessage(),null);
    }


}
